package com.wm.walmart.controller;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.wm.walmart.entity.Department;
import com.wm.walmart.mapper.DepartmentMapper;
import com.wm.walmart.service.IDepartmentService;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author xieyize
 * @since 2019-12-09
 */
@RestController
@RequestMapping("/department/")
public class DepartmentController {
	@Resource
	private IDepartmentService deptService;

	/**
	 * 添加部门信息 http://localhost:8080/walmart/department/insertDept?dptName=学习部
	 */
	@RequestMapping("insertDept")
	public Object insertDept(Department dept) {
		return deptService.save(dept);
	}

	/**
	 * 根据id修改部门信息
	 * http://localhost:8080/walmart/department/updateDept?dptId=7&dptName=学习部1
	 */
	@RequestMapping("updateDept")
	public Object updateDept(Department dept) {
		return deptService.updateById(dept);
	}

	/**
	 * 根据id删除部门信息 http://localhost:8080/walmart/department/deleteDeptById?dptId=7
	 */
	@RequestMapping("deleteDeptById")
	public Object deleteDeptById(Integer dptId) {
		return deptService.removeById(dptId);
	}
	
	/**
	 * 根据id查询删除部门信息 http://localhost:8080/walmart/department/selecdtDeptById?dptId=1
	 */
	@RequestMapping("selecdtDeptById")
	public Object selecdtDeptById(Integer dptId) {
		return deptService.selectDeptById(dptId);
	}
}
